﻿using System.Drawing;
using System.Windows.Forms;

namespace GDI
{
    public partial class MainForm : Form
    {
        private readonly TextMarker f_Marker = new TextMarker
        {
            Value = "Test",
            TextColor = Color.Black,
            BackgroundColor = Color.Transparent,
            Angle = 120
        };

        private readonly Line f_VerticalLine = new Line
        {
            Begin = new PointF { X = 100, Y = 0 },
            End = new PointF { X = 100, Y = 500 },
            LinePen = new Pen(Color.Red, 2)
        };

        private readonly Line f_HorizontalLine = new Line
        {
            Begin = new PointF { X = 0, Y = 100 },
            End = new PointF { X = 500, Y = 100 },
            LinePen = new Pen(Color.Red, 2)
        };

        private readonly Line f_TestLine = new Line
        {
            Begin = new PointF(-50, 0),
            End = new PointF(50, 0),
            LinePen = new Pen(Color.LimeGreen, 2)
        };

        public MainForm()
        {
            InitializeComponent();

            Paint += f_Marker;
            Paint += f_VerticalLine;
            Paint += f_HorizontalLine;
            Paint += f_TestLine;

            PrintableItem i = f_Marker;
            i.Position = new PointF(100, 100);

            i = f_TestLine;
            i.Position = new PointF(100, 100);
            i.Angle = 120;
        }

        private void OnMouseMove_EventHandler(object sender, MouseEventArgs e)
        {
            StatusLabel.Text = string.Format("({0}:{1})", e.X, e.Y);
        }

        [System.Diagnostics.DebuggerStepThrough]
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            //e.Graphics.InitializeLifetimeService

            base.OnPaint(e);
        }
    }
}
